package models;

import java.sql.ResultSet;
import java.sql.SQLException;

public class 
PurchaseItemModel 
extends AbstractModel
{	public boolean
	insert(Integer receiptId, Integer upc, Integer quantity)
	{	try{
			ps = con.prepareStatement("INSERT INTO PurchaseItem VALUES (?,?,?)");
			ps.setInt(1, receiptId);
			ps.setInt(2, upc);
			ps.setInt(3, quantity);
			return wrapUp();
		} catch(SQLException ex){ return registerException(ex); }
	}

	public boolean
	delete(int receiptId, int upc)
	{ 	try{
			ps = con.prepareStatement("DELETE FROM PurchaseItem WHERE upc = ? AND receiptId = ?");
			ps.setInt(1,upc);
			ps.setInt(2,receiptId);
			return wrapUp();
		} catch(SQLException ex){ return registerException(ex); }
	}
	
	public ResultSet
	show()
	{ return super.show("PurchaseItem"); }
}
